version 8.2
capture clear
capture log close
set more off
set mem 5000m
set mat 2000


****Table D1D2:

clear
*create a list of the description of the sectors
use "Enterprise surveys_judicial_reforms_standardized dataset.dta"
sort d1a2
keep if d1a2!=d1a2[_n-1]
keep d1a2 description
save "List description sectors.dta", replace


use "Germany-2009-MOI-full data.dta"
count
sort d1a2 
merge d1a2 using "List description sectors.dta"
codebook _merge
drop if _merge==2

sort moie17
browse d1a1x d1a2 description if moie17==5
*d1a1x: in the last complete fiscal year, what was this establishment�s main product?
*d1a2: please choose 4-digit code that best applies to main product of this est.
browse d1a1x d1a2 description if moie17==1


*Table D3
*Balancing table along the specific=1, specific=0 dimension
clear

use "Enterprise surveys_judicial_reforms_standardized dataset.dta"

label variable h7a "Judicial efficiency"
replace va_perwo_ppp_trim1 =va_perwo_ppp_trim1 /1000
label variable va_perwo_ppp_trim1 "Value added per worker (Thousand dollars)"
replace n7_perwo_ppp_trim1=n7_perwo_ppp_trim1/1000
label variable n7_perwo_ppp_trim1 "Capital stock per worker (Thousand dollars)" 
label variable prop_skill "Proportion of skilled workers" 
label variable size_num "Number employees" 
label variable new_firm "New firm" 

global list_var h7a va_perwo_ppp_trim1 n7_perwo_ppp_trim1 prop_skill size_num new_firm ///*Firm data

gen inverse_DJ4g1m=1-DJ4g1m
eststo specific_generic: estpost ttest $list_var, by(inverse_DJ4g1m)

*esttab specific_generic using "TableD3.xls", csv plain cells("mu_1(label(Specific) fmt(2)) mu_2(label(Generic)) b(label(Specific-Generic) star pvalue(p))" ". . t(label(t-stat) par)") mtitles("Specific vs Generic") noobs replace label star(* 0.10 ** 0.05 *** 0.01) ///
*title(Table: Firms in specific and generic sectors)

esttab specific_generic using "Table D3.tex", tex plain cells("mu_1(label(Specific) fmt(2)) mu_2(label(Generic)) b(label(Specific-Generic) star pvalue(p))" ". . t(label(t-stat) par)") mtitles("Specific vs Generic") noobs replace label star(* 0.10 ** 0.05 *** 0.01) ///
title(Table: Firms in specific and generic sectors)



exit
